home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 8542 / 8542.xpi / chrome / lastpass.jar / content / home.js < prev    next >
Text File  |  2010-02-14  |  17KB  |  54 lines

  1. var tree;var timerId=null;var lastLoginState;var accts_version=-1;var curr_username="";var last_action_hidden=null;var tdoc=null;var twin=null;function window_load(B,A){tdoc=B;twin=A;if(LP.lpisp()){B.getElementById("ads").style.display="none";B.getElementById("adsspacer").style.display="none"}B.title=LP.lpgs("My LastPass Vault");
  2. LP.sr(B,"lpt_lpfillformsmenu5","label","Fill Forms");LP.sr(B,"addsecurenote","value","AddSecureNote");LP.sr(B,"addsecurenote","hidden",LP.lphidenotes);LP.sr(B,"labelidentity","value","Identity");LP.sr(B,"accountsettings","value","Account Settings");LP.sr(B,"lphomemore","label","More");LP.sr(B,"prefs","label","Preferences");
  3. LP.sr(B,"history","label","History");LP.sr(B,"showdeleted","label","Show Deleted Sites");LP.sr(B,"changepassword","label","Change Password");LP.sr(B,"forums","label","Forums");LP.sr(B,"blog","label","Blog");LP.sr(B,"logofflink","value","Logoff");LP.sr(B,"sethomepage","label","Make this my home page!");
  4. LP.sr(B,"searchBtn","label","Search");LP.sr(B,"clearBtn","label","Clear");LP.sr(B,"nositeslabel","value","NoSites");LP.sr(B,"browsenormallylabel","value","BrowseNormally");LP.sr(B,"watchvideolabel","value","Watch a video on basic usage");LP.sr(B,"expandall","value","Expand All");LP.sr(B,"collapseall","value","Collapse All");
  5. LP.sr(B,"tname","label","Name");LP.sr(B,"tusername","label","Username");LP.sr(B,"turl","label","URL");LP.sr(B,"tlasttouch","label","Last Touch");LP.sr(B,"taction1","label","Action");LP.sr(B,"taction2","label","Share");LP.sr(B,"taction3","label","Delete");LP.sr(B,"tnote","label","Contains Note");LP.sr(B,"tpwprotect","label","Requires Password Reprompt");
  6. LP.sr(B,"tautologin","label","Will AutoLogin");if(LP.getLoggedIn()){window_load_loggedin();curr_username=LP.getUsername()}else{window_load_loggedoff();getel("lpsearchstr").focus()}tree=getel("tree");lastLoginState=LP.getLoggedIn();timerId=setInterval("checkLoggedInHome()",500);window.addEventListener("DOMMouseScroll",scroll,false);
  7. if(LP.IsHomePage()){var C=document.getElementById("sethomepage");C.setAttribute("hidden","true")}doonresize();window.addEventListener("resize",doonresize,false)}function doonresize(){var A=document.getElementById("tree");if(typeof(A.getBoundingClientRect)=="function"){A.height=window.innerHeight-A.getBoundingClientRect().top
  8. }var B=document.getElementById("logofflink");var D=document.getElementById("headerspacer");if(typeof(B.getBoundingClientRect)=="function"){var C=parseInt(D.style.width.replace("px",""));D.style.width=Math.max(1,Math.floor(C+window.innerWidth-B.getBoundingClientRect().right-20))+"px"}else{D.flex=100}}function scroll(C){if(""!=curr_username){if(tree!=C.target){var B=document.createEvent("MouseScrollEvents");
  9. B.initMouseEvent(C.type,C.bubbles,C.cancelable,C.view,C.detail,C.screenX,C.screenY,C.clientX,C.clientY,C.ctrlKey,C.altKey,C.shiftKey,C.metaKey,C.button,C.relatedTarget);var A=tree.dispatchEvent(B);if(A){}}}}function window_unload(){if(timerId!=null){clearInterval(timerId);timerId=null}window.removeEventListener("resize",doonresize,false)
  10. }function window_sethomepage(){var A=document.getElementById("sethomepage");A.setAttribute("hidden","true");LP.SetHomePage()}function getel(A){return document.getElementById(A)}function oncommandIdentity(B,A){if(LP.getLoggedIn()){LP.lpIdentityHelper(A,false);syncVaultIdentity(true)}}function syncVaultIdentity(D){if(LP.getLoggedIn()){var C=document.getElementById("identitylist");
  11. var B=C.selectedIndex>=0?C.value:-1;var A=LP.GetIdentity(false);if(B!=A){LP.updateVaultSelectedIdentity(document,false)}if(!D){setTimeout("syncVaultIdentity()",1000)}}}function window_load_loggedin(){tree=getel("tree");tree.setAttribute("hidden",false);getel("expandcollapse").setAttribute("hidden",false);
  12. getel("lpsearchstr").focus();var A=window.arguments;if(A&&A.length>0&&typeof(A[0])!="undefined"){var C=A[0];var B=getel("lpsearchstr");if(B){B.value=C}LP.search_tree_accept_click(document,window)}else{LP.search_tree_accept_click(document,window)}if(accts_version>-1&&getel("nosites")){fix_nosites()}if(getel("topusername")){getel("topusername").value=LP.getUsername();
  13. getel("topusername").className="header";getel("topusername").onclick=""}update_identity_popup(false);if(getel("logofflink")){getel("logofflink").setAttribute("disabled",false)}if(getel("addsecurenote")){getel("addsecurenote").setAttribute("disabled",false)}if(getel("accountsettings")){getel("accountsettings").setAttribute("disabled",false)
  14. }LP.lp_fix_formfills_menus_helper(document,1);if(getel("lpt_lpfillformsmenu5")){getel("lpt_lpfillformsmenu5").setAttribute("style","")}if(getel("lphomemore")){getel("lphomemore").setAttribute("style","");getel("lphomemore").setAttribute("disabled",false)}restoreGroupState("window_load_loggedin");doonresize()
  15. }function fix_nosites(){if(LP.numsites()){getel("nosites").setAttribute("hidden",true)}else{if(LP.GetIdentity(false)!=""){LP.sr(document,"nositeslabel","value","You do not yet have any sites setup for your currently selected identity!");LP.sr(document,"browsenormallylabel","value","Please change your identity back to 'All' to view a complete listing of your sites.");
  16. LP.sr(document,"watchvideolabel","value","")}else{LP.sr(document,"nositeslabel","value","NoSites");LP.sr(document,"browsenormallylabel","value","BrowseNormally");LP.sr(document,"watchvideolabel","value","Watch a video on basic usage")}getel("nosites").setAttribute("hidden",false)}}function update_identity_popup(E){if(getel("identitypopup")){var D=getel("identitypopup");
  17. for(var B=D.childNodes.length-1;B>=0;--B){D.removeChild(D.lastChild)}getel("labelidentity").setAttribute("style","");getel("identitylist").setAttribute("style","");getel("identitylist").setAttribute("disabled",false);var F=LP.getIdentities();for(var B=0;B<F.length;++B){F[B]["id"]="identity_"+B;F[B]["oncommand"]="oncommandIdentity('"+F[B]["id"]+"','"+F[B]["value"]+"')";
  18. var C=document.createElement("menuitem");for(var A in F[B]){C.setAttribute(A,F[B][A])}D.appendChild(C)}syncVaultIdentity(E)}clear_click()}function window_load_loggedoff(){tree=getel("tree");tree.setAttribute("hidden",true);getel("expandcollapse").setAttribute("hidden",true);if(getel("nosites")){getel("nosites").setAttribute("hidden",true)
  19. }if(getel("topusername")){getel("topusername").value=LP.lpgs("Login");getel("topusername").className="text-link header";getel("topusername").onclick=function(){LP.lpOpenLogin()}}if(getel("logofflink")){getel("logofflink").setAttribute("disabled",true)}if(getel("addsecurenote")){getel("addsecurenote").setAttribute("disabled",true)
  20. }if(getel("accountsettings")){getel("accountsettings").setAttribute("disabled",true)}LP.lp_fix_formfills_menus_helper(document,1);if(getel("lpt_lpfillformsmenu5")){getel("lpt_lpfillformsmenu5").setAttribute("style","color: graytext")}if(getel("lphomemore")){getel("lphomemore").setAttribute("style","color: graytext");
  21. getel("lphomemore").setAttribute("disabled",true)}if(getel("identitypopup")){getel("labelidentity").setAttribute("style","color: graytext");getel("identitylist").setAttribute("style","color: graytext");getel("identitylist").setAttribute("disabled",true)}doonresize()}function load_ads(){if(getel("ads")&&typeof(document.lpadsloaded)=="undefined"&&LP.isconnected()&&!LP.lpisp()){document.lpadsloaded=true;
  22. setTimeout("getel('ads').webNavigation.loadURI(LP.lp_base + 'ads.php', null, null, null, null);",0)}}function checkLoggedInHome(){load_ads();var A=LP.getLoggedIn();var G="";if(A){G=LP.getUsername()}if(A!=lastLoginState||G!=curr_username){if(A){window_load_loggedin()}else{var F=getel("searchresults");
  23. while(F.firstChild){F.removeChild(F.firstChild)}window_load_loggedoff();accts_version=-1}}lastLoginState=A;curr_username=G;if(lastLoginState){var C=LP.get_local_accts_version();if(C>accts_version||LP.IsIconsUpdated()){if(LP.lpisp()){document.getElementById("ads").style.display="none";document.getElementById("adsspacer").style.display="none"
  24. }else{document.getElementById("ads").style.display="";document.getElementById("adsspacer").style.display="";load_ads()}accts_version=C;fix_nosites();LP.search_tree_accept_click(document,window);LP.lp_fix_formfills_menus_helper(document,1);var B=document.getElementById("lpmorepopup");if(B){var D=document.getElementById("admintools");
  25. if(LP.isadmin()){if(!D){var E=document.createElement("menuitem");E.setAttribute("id","admintools");E.setAttribute("label",LP.lpgs("Admin Tools"));E.setAttribute("oncommand","LP.lpAdminPage();");B.appendChild(E)}}else{if(D&&D.parentNode==B){B.removeChild(D)}}}update_identity_popup(true)}}}function clear_click(){var A=getel("lpsearchstr");
  26. if(A){A.value=""}LP.search_tree_accept_click(document,window);A.focus();restoreGroupState("clear_click")}function saveGroupState(A){LP.saveGroupState(document,A)}function restoreGroupState(A){LP.restoreGroupState(document,A)}var columnpickervisible=false;function onTreeClicked(T){var d=document;if(T.ctrlKey||T.shiftKey){return
  27. }var P=getel("tree");var H=P.treeBoxObject;var N={},K={},M={};H.getCellAt(T.clientX,T.clientY,N,K,M);var B=document.getAnonymousElementByAttribute(T.originalTarget,"anonid","popup");if(B!=null){B.setAttribute("onpopupshowing","columnpickervisible=true;");B.setAttribute("onpopuphiding","columnpickervisible=false;")
  28. }if(columnpickervisible){return}var F=false;if(T.button==0){if(N.value==-1||M.value=="twisty"){F=true;saveGroupState("clicktwisty")}else{if(H.view.isContainer(N.value)){var I=P.view.getCellText(N.value,K.value);H.view.toggleOpenState(N.value);F=true;saveGroupState("clickrow")}}}else{if(T.button==2){if(N.value==-1){return
  29. }var X=P.view.getItemAtIndex(N.value);if(X==null){return}var J=X.getAttribute("isgroup");var D=document.getElementById("rightclickmenu");while(D.firstChild){D.removeChild(D.firstChild)}getSelected();if(tdoc.selected_ids.length>0||!J){var S="";var Q="";var L=0;if(tdoc.selected_ids.length>0){for(var V=0;
  30. V<tdoc.selected_ids.length;V++){if(""==Q){Q=tdoc.selected_ids[V]}S+=tdoc.selected_ids[V]+",";L++}}else{var R=X.getAttribute("id");Q=R;S=R;L++}var C=document.createElement("menuitem");C.setAttribute("oncommand","OpenMoveGroupDlg()");C.setAttribute("label",(tdoc.selected_ids.length>1?LP.lpgs("Move Selected to Group"):LP.lpgs("Move to Group")));
  31. var A=document.createElement("menuitem");A.setAttribute("oncommand","LP.lpOpenShareWindow('"+S+"');");A.setAttribute("label",(tdoc.selected_ids.length>1?LP.lpgs("Share Selected"):LP.lpgs("Share")));var c=document.createElement("menuitem");c.setAttribute("oncommand","ConfirmMultipleDelete()");c.setAttribute("label",(tdoc.selected_ids.length>1?LP.lpgs("Delete Selected"):LP.lpgs("Delete")));
  32. var a=document.createElement("menuitem");a.setAttribute("oncommand","OpenEdit('"+Q+"')");a.setAttribute("label",LP.lpgs("Edit"));D.appendChild(a);if(tdoc.selected_ids.length==1){var Z=document.createElement("menuitem");Z.setAttribute("oncommand","LP.lpCopyUsername('"+Q+"')");Z.setAttribute("label",LP.lpgs("Copy Username"));
  33. var G=document.createElement("menuitem");G.setAttribute("oncommand","LP.lpCopyPassword('"+Q+"')");G.setAttribute("label",LP.lpgs("Copy Password"));D.appendChild(Z);D.appendChild(G)}D.appendChild(C);D.appendChild(A);D.appendChild(c);D.appendChild(a);var E=document.createElement("menuitem");E.setAttribute("oncommand","LP.GotoURL('"+Q+"')");
  34. E.setAttribute("label",LP.lpgs("Go to URL"));D.appendChild(E)}else{var O=X.getAttribute("orig_group");if(O!=LP.lpgs("favorites")&&O!=LP.lpgs("recently used")){var C=document.createElement("menuitem");C.setAttribute("oncommand","LP.openChangeGroupDlg('"+LP.lpes(O)+"');");C.setAttribute("label",LP.lpgs("Rename Group"));
  35. D.appendChild(C);var b=document.createElement("menuitem");b.setAttribute("oncommand","ConfirmMultipleDelete('"+LP.lpes(O)+"');");b.setAttribute("label",LP.lpgs("Delete Group"));D.appendChild(b);var A=document.createElement("menuitem");A.setAttribute("oncommand","SubGroup('"+LP.lpes(O)+"');");A.setAttribute("label",LP.lpgs("Create Sub-Group"));
  36. D.appendChild(A)}var c=document.createElement("menuitem");c.setAttribute("oncommand","OpenGroup('"+LP.lpes(O)+"',"+N.value+");");c.setAttribute("label",LP.lpgs("Open All"));D.appendChild(c)}if(typeof(D.openPopupAtScreen)=="function"){D.openPopupAtScreen(T.screenX,T.screenY,false)}else{D.showPopup(null,T.screenX,T.screenY,"popup")
  37. }return}}if(F&&N.value!=-1){try{var Y=H.view.getItemAtIndex(N.value);Y.firstChild.firstChild.setAttribute("src","chrome://lastpass/skin/folder-"+(Y.getAttribute("open")=="true"?"open":"closed")+".gif")}catch(W){}return}if(N.value!=-1){try{var I=P.view.getCellText(N.value,K.value);
  38. var X=P.view.getItemAtIndex(N.value);var U=P.view.getImageSrc(N.value,K.value);var R=X.getAttribute("id");if(!R){return}if(LP.lpgs("Share")==I){LP.lpOpenShareWindow(R)}else{if(LP.lpgs("Delete")==I){LP.lpConfirmDeleteSite(R)}else{if(LP.lpgs("Edit")==I){LP.lpOpenEditWindow(R,0,0,window)}else{if(LP.lpgs("Reject")==I){LP.lpOpenRejectShareWindow(R)
  39. }else{if(LP.lpgs("Accept")==I){LP.lpOpenAcceptShareWindow(R)}else{if(U=="chrome://lastpass/skin/page_edit.png"||U=="chrome://lastpass/skin/lock.png"||U=="chrome://lastpass/skin/accounts.png"){LP.lpOpenEditWindow(R,0,0,window)}else{if(K.value.index==0){if(M.value=="text"){if(LP.is_secure_note(R)){LP.lpOpenEditWindow(R,0,0,window)
  40. }else{if(LP.is_pending_share(R)){LP.lpOpenAcceptShareWindow(R)}else{LP.lpLaunchUrl(R,1,0)}}}}}}}}}}}catch(W){}}}function sort(D){var B;var A=tree.getAttribute("sortDirection")=="ascending"?1:-1;if(D){B=D.id;if(tree.getAttribute("sortResource")==B){A*=-1}}else{B=tree.getAttribute("sortResource")
  41. }tree.setAttribute("sortDirection",A==1?"ascending":"descending");tree.setAttribute("sortResource",B);var E=tree.getElementsByTagName("treecol");for(var C=0;C<E.length;C++){E[C].removeAttribute("sortDirection")}getel(B).setAttribute("sortDirection",A==1?"ascending":"descending");LP.search_tree_accept_click(document,window)
  42. }function prepareForComparison(A){if(typeof A=="string"){return A.toLowerCase()}return A}function handleTreeMouseMove(D){if(D.target.localName!="treechildren"){return}var A=D.target.parentNode;var C=A.treeBoxObject;var F={},B={},E={};C.getCellAt(D.clientX,D.clientY,F,B,E);window.top.XULBrowserWindow.setOverLink(cell.uri,null)
  43. }function collapseall(){var A=document.getElementById("tree");var B=A.treeBoxObject.view;for(var C=0;C<B.rowCount;C++){if(B.isContainer(C)&&B.isContainerOpen(C)){B.toggleOpenState(C);var D=B.getItemAtIndex(C);D.firstChild.firstChild.setAttribute("src","chrome://lastpass/skin/folder-closed.gif")}}saveGroupState("collapseall")
  44. }function expandall(){var A=document.getElementById("tree");var B=A.treeBoxObject.view;for(var C=0;C<B.rowCount;C++){if(B.isContainer(C)&&!B.isContainerOpen(C)){B.toggleOpenState(C);var D=B.getItemAtIndex(C);D.firstChild.firstChild.setAttribute("src","chrome://lastpass/skin/folder-open.gif")}}saveGroupState("expandall")
  45. }function clearURLFromStatusBar(){window.top.XULBrowserWindow.setOverLink("",null)}function getTreeItemFromEvent(A){var J=getel("tree");var E=J.treeBoxObject;var I={},D={},C={};E.getCellAt(A.clientX,A.clientY,I,D,C);var B=null;if(I.value!=-1){try{var F=J.view.getCellText(I.value,D.value);var H=J.view.getImageSrc(I.value,D.value);
  46. B=J.view.getItemAtIndex(I.value)}catch(G){B=null}}return B}function getSelected(){var A=getel("tree");tdoc.selected_ids=new Array();tdoc.selected_groups=new Array();getSelectedRowsInTree(A,tdoc.selected_ids,tdoc.selected_groups)}function getSelectedRowsInTree(M,B,E){var A=M.view.selection.getRangeCount();
  47. var L=new Object();var I=new Object();for(var H=0;H<A;H++){M.view.selection.getRangeAt(H,L,I);for(var G=L.value;G<=I.value;G++){var D=null;try{D=M.view.getItemAtIndex(G)}catch(J){continue}if(!D){continue}if(D.hasAttribute("isgroup")){continue}var C=D.getAttribute("id");var K=false;for(var F=0;F<B.length;
  48. F++){if(B[F]==C){K=true;break}}if(!K){B[B.length]=D.getAttribute("id");E[E.length]=D.getAttribute("group")}}}}var siteObserver={onDragStart:function(E,B,F){var A=getel("tree");var D=A.treeBoxObject;var G={},C={},H={};D.getCellAt(E.clientX,E.clientY,G,C,H);if(C.value==null){return}tdoc.selected_ids=new Array();
  49. tdoc.selected_groups=new Array();getSelectedRowsInTree(A,tdoc.selected_ids,tdoc.selected_groups);B.data=new TransferData();B.data.addDataForFlavour("text/unicode","not used")},getSupportedFlavours:function(){var A=new FlavourSet();A.appendFlavour("text/unicode");return A},onDragOver:function(B,E,D){var F=getTreeItemFromEvent(B);
  50. var C=F.getAttribute("orig_group");if(C==""||C==LP.lpgs("recently used")){return}for(var A=0;A<tdoc.selected_groups.length;A++){if(C!=tdoc.selected_groups[A]){D.canDrop=true;return}}D.canDrop=false},dragover:function(B){var D=getTreeItemFromEvent(B);var C=D.getAttribute("orig_group");if(C==""||C==LP.lpgs("recently used")){return
  51. }for(var A=0;A<tdoc.selected_groups.length;A++){if(C!=tdoc.selected_groups[A]){B.preventDefault();return}}},drop:function(B,A){var D=getTreeItemFromEvent(B);if(!D){return}var C=D.getAttribute("orig_group");if(""==C){C=D.getAttribute("orig_group")}if(C!=LP.lpgs("recently used")){LP.moveSelectedToGroup(C,tdoc,twin)
  52. }B.stopPropagation()}};function OpenGroup(A,B){LP.OpenGroup(tree,A,B)}function OpenMoveGroupDlg(){LP.openMoveGroupDlg(tdoc,twin)}function SubGroup(A){LP.OpenSubGroupDlg(A,tdoc)}function ConfirmMultipleDelete(A){LP.ConfirmMultipleDelete(tdoc,twin,A)}function OpenEdit(A){LP.lpOpenEditWindow(A,0,0,twin)
  53. };
  54.